#include <iostream>
#include <vector>
#include <set>
using namespace std;
class Solution
{
public:
    int countPoints(string rings)
    {
        vector<set<char>> poles;
        for (int i = 0; i < 10; ++i)
        {
            set<char> set;
            poles.emplace_back(set);
        }

        for (int i = 0; i < rings.length(); i += 2)
        {
            poles[rings[i + 1] - '0'].insert(rings[i]);
        }

        int res = 0;
        for (int i = 0; i < poles.size(); ++i)
        {
            if (poles[i].size() == 3)
                ++res;
        }
        return res;
    }
    int countPoints_2(string rings)
    {
        vector<vector<int>> ans(10, vector<int>(3, 0));
        int res = 0, n = rings.length();
        if (6 > n)
        {
            return 0;
        }
        for (int i = 1; i < n; i += 2)
        {
            int index = rings[i] - '0';
            char c = rings[i - 1];
            if (c == 'R')
            {
                ans[index][0] = 1;
            }
            else if (c == 'G')
            {
                ans[index][1] = 1;
            }
            else
            {
                ans[index][2] = 1;
            }
        }
        for (int i = 0; i < 10; i++)
        {
            if (ans[i][0] == 1 && ans[i][1] == 1 && ans[i][2] == 1)
                res++;
        }
        return res;
    }
};
int main()
{

    system("pause");
    return 0;
}
